//
//  StatusCellBottomVIew.swift
//  Weibo
//
//  Created by apple on 15/12/12.
//  Copyright © 2015年 idcast. All rights reserved.
//

import UIKit
///底部视图
class StatusCellBottomVIew: UIView {
    // 
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    //懒加载数据
    ///转发按钮
    private lazy var retweetButton: UIButton = UIButton(title: " 转发", fontSize: 12, color: UIColor.darkGrayColor(), imageName: "timeline_icon_retweet")
    ///评论
    private lazy var commentButton: UIButton = UIButton(title: " 评论", fontSize: 12, color: UIColor.darkGrayColor(), imageName: "timeline_icon_comment")
    ///赞
    private lazy var lickButton: UIButton = UIButton(title: " 赞", fontSize: 12, color: UIColor.darkGrayColor(), imageName: "timeline_icon_unlike")

}

//设置布局
extension StatusCellBottomVIew {
    private func setupUI() {
        //0 设置背景颜色
        backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        //1 添加控件
        addSubview(retweetButton)
        addSubview(commentButton)
        addSubview(lickButton)
        //2 设置布局
        //转发按钮
        retweetButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
        }
        //评论按钮
        commentButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetButton.snp_top)
            make.left.equalTo(retweetButton.snp_right)
            make.width.equalTo(retweetButton.snp_width)
            make.height.equalTo(retweetButton.snp_height)
        }
        //赞按钮
        lickButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(commentButton.snp_top)
            make.left.equalTo(commentButton.snp_right)
            make.height.equalTo(commentButton.snp_height)
            make.width.equalTo(commentButton.snp_width)
            
            
            make.right.equalTo(self.snp_right)
        }
        
        //分隔视图
        let sep1 = sepView()
        let sep2 = sepView()
        addSubview(sep1)
        addSubview(sep2)
        //布局
        let w = 0.5
        let scale = 0.4
        sep1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetButton.snp_right)
            make.centerY.equalTo(retweetButton.snp_centerY)
            make.width.equalTo(w)
            make.height.equalTo(retweetButton.snp_height).multipliedBy(scale)
        }
        sep2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.centerY.equalTo(commentButton.snp_centerY)
            make.width.equalTo(w)
            make.height.equalTo(retweetButton.snp_height).multipliedBy(scale)
        }
        
    }
    private func sepView() -> UIView {
    
        let v = UIView()
        v.backgroundColor = UIColor.darkGrayColor()
        return v
    }
    
}